package org.vectrics.recruiter.struts;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

import org.vectrics.common.html.Cell;
import org.vectrics.common.html.Form;
import org.vectrics.common.html.Row;
import org.vectrics.common.html.Table;
import org.vectrics.hibernate.ThreadProperties;
import org.vectrics.struts.VectricsTagSupport;
import org.vectrics.user.Person;

public abstract class AdminSubMenuTag extends VectricsTagSupport {
	
	private static final long serialVersionUID = 817815518266397944L;

	private List itemHtmlList = new ArrayList(); 
	
	public AdminSubMenuTag() {
		super();
	}

	abstract void fillList(List itemHtmlList);

	protected String makeStartTag() {
		itemHtmlList.clear();
		Table menuTable = new Table();
		menuTable.setCellPadding(1);
		menuTable.setCellSpacing(1);
		fillList(itemHtmlList);
		Iterator iter = itemHtmlList.iterator();
		while (iter.hasNext()) {
			Object element = (Object)iter.next();
			Row row = menuTable.addRow();
			Cell cell = row.addCell();
			cell.addElement(element.toString());
		}
		
		return(menuTable.toString());
	}
	
	public Form createButtonForm(String action, String captionPhraseCode, String formId) {
		return ButtonUtils.createButtonForm(this.getRequest(), action, captionPhraseCode, this.getLocale(),
				formId, "submit", "submit");
	}
	
    protected Person getAuthPerson() {
    	return ThreadProperties.getPerson();
    }
    
}
